from Entities.Calendars.Calendar import Calendar

class SimpleCalendar (Calendar):
    '''
    Calendar with name 'name'
    '''
    
    def __init__ \
        (
        self, 
        code, 
        name, 
        holidays  = None
        ):
        Calendar.__init__(self, code, name)
        if holidays == None:
            self.holidays = []
        else:
            self.holidays  = holidays
        
    def isholiday (self, when):
        for holiday in self.holidays:
            if holiday.isholiday (when):
                return True
        return False
    
    def __repr__ (self):
        res = "<%s('%s', %s)>\n" % \
            (
            self.__class__.__name__,
            self.code,
            self.name,
            )
        for hol in self.holidays:
            res += "    " + hol.__repr__ () + '\n'
        return res
            
